using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Windows.Media;
using System.Windows.Browser;

namespace TFSWorkflowControl.TSWA.SL
{
    public class RevisionCollection
    {
        public List<Revision> RevisionList { get; private set; }
        public List<string> FieldList { get; private set; }

        public RevisionCollection()
        {
            RevisionList = new List<Revision>();
            FieldList = new List<string>();
        }

        [ScriptableMember(ScriptAlias="AppendRev")]
        public void AppendRevision(
            string state,
            string who,
            string reason,
            int year,
            int month,
            int day)
        {
            var rev = new Revision(state, who, reason, new DateTime(year, month, day));
            RevisionList.Add(rev);
        }

        [ScriptableMember(ScriptAlias="Set")]
        public void SetFieldValueToLastRevision(string field, string value)
        {
            int c = RevisionList.Count;

            if (c == 0)
            {
                return;
            }

            RevisionList[c - 1].SetFieldValue(field, value);

            if (!FieldList.Contains(field))
            {
                FieldList.Add(field);
                FieldList.Sort();
            }
        }



    }
}
